# _*_ coding:utf-8 _*_
# @Time : 2023/5/25 17:57
# @Author : wsl
# @File : day05_demo
# @Project : python  handle 更高级的对象定制

import urllib.request
import urllib.error

# 域名或者后面的接口错误
url = 'http://www.baidu.com'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0'
}

request = urllib.request.Request(url=url, headers=headers)
handler = urllib.request.HTTPHandler()
opener = urllib.request.build_opener(handler)
response = opener.open(request)
print(response.read().decode('utf-8'))
